#laptop
setwd('/Users/joelsievert/Dropbox/Research/Electoral Institutions/DRDR/journal submissions/JPIPE/final submission/Replication Materials')


m <- read.csv('jpipe_tab1.csv')

######################
#political background#
######################

#state legislator
sl.tab <- xtabs(~legis_exp + senator, m)
chisq.test(sl.tab)
prop.table(sl.tab, 2)

#electoral experience
exp.tab <- xtabs(~electoral_exp + senator, m)
chisq.test(exp.tab)
prop.table(exp.tab, 2)

#political dynasty
fam.tab <- xtabs(~ fam_bin + senator, m)
chisq.test(fam.tab)
prop.table(fam.tab, 2)

#level of gov't service
lvl.tab <- xtabs(~gov_lvl + senator, m)
chisq.test(lvl.tab)
prop.table(lvl.tab, 2)

#multiple levels of service
multi.tab <- xtabs(~multi_gov + senator, m)
chisq.test(multi.tab)
prop.table(multi.tab, 2)


#########################
#professional background#
########################

####################
#college attendance#
###################

#categories
#0: no college
#1 state uni
#2 ivy league 
#3 other

m$gol_grad <- NA
m$col_grad[m$college > 0] <- 1
m$col_grad[m$college == 0] <- 0

m$ivy <- NA
m$ivy[m$college == 2] <- 1
m$ivy[m$college != 2] <- 0

c.tab <- xtabs(~col_grad + senator, m )
chisq.test(c.tab)
prop.table(c.tab, 2)

i.tab <- xtabs(~ivy + senator, m )
chisq.test(i.tab)
prop.table(i.tab, 2)

############
#occupation#
###########

m$occup_tri <- 0
m$occup_tri[m$occup == 4] <- 1 #business
m$occup_tri[m$occup == 2] <- 2 #lawyer

o.tab <- xtabs(~occup_tri + senator, m )
chisq.test(o.tab)
prop.table(o.tab, 2)

##########
#military#
##########

#categories 
#0: none
#1: enlisted
#2: office
m.tab <- xtabs(~military + senator, m )
chisq.test(m.tab)
prop.table(m.tab, 2)






